﻿using System.Data;
using System.Data.SqlClient;

namespace MyWeb.Data
{
    public class CustomerController : SqlDataProvider
    {
        #region [Customer_GetByAll]

        public DataTable Customer_GetByAll()
        {
            return GetDataTable("sp_Customer_GetByAll");
        }

        #endregion

        #region [Customer_GetById]

        public DataTable Customer_GetById(int Id)
        {
            var p1 = new SqlParameter("@id", Id);
            return GetDataTable("sp_Customer_GetById", p1);
        }

        #endregion

        #region [Customer_Insert]

        public void Customer_Insert(CustomerInfo customer)
        {
            var p1 = new SqlParameter("@name", customer.Name);
            var p2 = new SqlParameter("@birthday", customer.Birthday);
            var p3 = new SqlParameter("@Address", customer.Address);
            var p4 = new SqlParameter("@tel", customer.Tel);
            var p5 = new SqlParameter("@email", customer.Email);
            ExecuteStoreProcedure("sp_Customer_Insert", p1, p2, p3, p4, p5);
        }

        #endregion

        #region [Customer_Update]

        public void Customer_Update(CustomerInfo customer)
        {
            var p0 = new SqlParameter("@id", customer.Id);
            var p1 = new SqlParameter("@name", customer.Name);
            var p2 = new SqlParameter("@birthday", customer.Birthday);
            var p3 = new SqlParameter("@Address", customer.Address);
            var p4 = new SqlParameter("@tel", customer.Tel);
            var p5 = new SqlParameter("@email", customer.Email);
            ExecuteStoreProcedure("sp_Customer_Update", p0, p1, p2, p3, p4, p5);
        }

        #endregion

        #region [Customer_Delete]

        public void Customer_Delete(int id)
        {
            var p0 = new SqlParameter("@id", id);
            ExecuteStoreProcedure("sp_Customer_Delete", p0);
        }

        #endregion
    }
}